package com.own.business.message.center.entity.bo;

import com.own.business.message.center.entity.po.MessageCenterContent;
import com.own.component.common.base.entity.BaseBo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * MessageCenterContentBo
 *
 * @author chenxueli
 * @date 2023-11-13 14:39:27
 */
@Schema(title = "消息中心内容" + ConstantBeanSuffix.BO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class MessageCenterContentBo extends BaseBo<MessageCenterContent> implements Serializable {

    /**
     * 接收消息的用户id
     */
    private Long receiveId;

    /**
     * 消息内容（展示的一小部分）
     */
    private String content;

    /**
     * 消息详情内容（json格式字符串）
     */
    private String detailContent;

    /**
     * 分组key
     */
    private String groupKey;

    /**
     * 消息key
     */
    private String messageKey;

    /**
     * 业务id
     */
    private Long businessId;

    /**
     * 是否已读（0=未读 1=已读）
     */
    private Integer isRead;

    /**
     * 已读时间
     */
    private LocalDateTime readTime;

    /**
     * 转持久化对象
     *
     * @param entity 原持久化对象
     * @return 持久化对象
     */
    @Override
    public MessageCenterContent toPo(MessageCenterContent entity) {
        if (entity == null) {
            entity = new MessageCenterContent();
        }
        entity.setFkReceiveId(this.receiveId);
        entity.setContent(this.content);
        entity.setDetailContent(this.detailContent);
        entity.setGroupKey(this.groupKey);
        entity.setMessageKey(this.messageKey);
        entity.setFkBusinessId(this.businessId);
        entity.setIsRead(this.isRead);
        entity.setReadTime(this.readTime);
        return super.toPo(entity);
    }

}

